//
// Created by Jisam on 2024/8/16 19:17.
// Solution of  T497979 因友情而终结
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

#define endl "\n"
#define PSI pair<string,int>
#define PII pair<int,int>
#define PDI pair<double,int>
#define PDD pair<double,double>
#define VVI vector<vector<int>>
#define VI vector<int>
#define VS vector<string>

#define PQLI priority_queue<int, vector<int>, less<int>>
#define PQGI priority_queue<int, vector<int>, greater<int>>
#define ui unsigned
#define lli long long
#define ulli unsigned long long
#define code_by_jisam ios::sync_with_stdio(false),cin.tie(nullptr)
using namespace std;
int cnt = 0;

// 构建next数组
vector<int> getNext(const string& pattern) {
    int n = pattern.size();
    vector<int> next(n, 0);

    int i = 1, j = 0;
    while (i < n) {
        if (pattern[i] == pattern[j]) {
            next[i] = j + 1;
            i++;
            j++;
        } else {
            if (j > 0) {
                j = next[j - 1];
            } else {
                next[i] = 0;
                i++;
            }
        }
    }
    return next;
}

// KMP算法匹配字符串
int kmp(const string& text, const string& pattern) {
    int m = text.size();
    int n = pattern.size();
    vector<int> next = getNext(pattern);

    int i = 0, j = 0;
    while (i < m) {
        if (text[i] == pattern[j]) {
            if (j == n - 1) {
                // 匹配成功，返回起始位置
//                return i - j;
                ++ cnt;
            }
            i++;
            j++;
        } else {
            if (j > 0) {
                j = next[j - 1];
            } else {
                i++;
            }
        }
    }

    // 未找到匹配
    return -1;
}
void solution(){
    string a,b= "friend";
    cin >> a;
    kmp(a,b);
    cout << cnt;
}
int main() {
    code_by_jisam;
    int T = 1;
//    cin >> T;
    while (T--) {
        solution();
    }
    return 0;
}